package com.yuyuan.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuyuan.blog.domain.po.BlogDaily;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: kestrel
 * @Version:1.0
 * @Date: 2024/5/29
 */
@Mapper
public interface DailyBlogMapper extends BaseMapper<BlogDaily> {
    @Select("select * from tb_blog_daily where id < #{start} and status < 2 order by create_time DESC,id DESC limit 6")
    List<BlogDaily> getDailies(Long start);
    @Select("select max(id) from tb_blog_daily where status < 2  order by id limit 1")
    Long getMaxStartId();
    @Update("update tb_blog_daily set likes=likes+1 where id = #{id} and status < 2")
    public boolean addLike(Long id);

    @Update("update tb_blog_daily set likes=likes-1 where id = #{id} and status < 2")
    public boolean subLike(Long id);

    BlogDaily queryHotBlog();
}
